package com.amor.ui

import android.content.Intent
import android.os.SystemClock
import android.view.ViewGroup
import android.webkit.WebSettings
import android.webkit.WebView
import com.amor.app.MyApplication
import com.amor.widget.ExWebView
import com.hy.frame.util.LogUtil


class StaticWebActivity : BaseWebActivity() {

    private var mWeb : ExWebView? = null

    override fun initView() {
        super.initView()
        initStartTime = SystemClock.elapsedRealtime()
        LogUtil.d(TAG, "初始化WebView start")
        mWeb = MyApplication.get().getWebViewHolder().build()
        initWebSettings(mWeb!!.settings, WebSettings.LOAD_DEFAULT)
        initClient(mWeb!!)
        mBinding?.container?.addView(mWeb, ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
        LogUtil.d(TAG, "初始化WebView end time=%sms".format(SystemClock.elapsedRealtime() - initStartTime))
        showConsole("初始化WebView耗时=%sms\n".format(SystemClock.elapsedRealtime() - initStartTime))
    }

    override fun initData() {
        super.initData()
        mWeb?.loadUrl("https://m.huize.com/mall/1")
    }

    override fun onNewIntent(intent: Intent?) {
        super.onNewIntent(intent)
        mWeb?.loadUrl("https://m.huize.com/mall/1")
    }

    override fun onBackPressed() {
        super.onBackPressed()
    }
    override fun onDestroy() {
        super.onDestroy()
        LogUtil.d(TAG, "onDestroy")
        mWeb?.clear()
        mWeb?.strip()
    }
}